package org.sam.swing.table.verification;

import java.util.Map;

import org.sam.swing.table.JSTableModel;

/**
 * 数据校验接口
 * 
 * @author sam
 *
 */
public interface Verification extends Verificat {

	/**
	 * 校验全部数据的操作
	 * 
	 * @param model
	 * @param msgs
	 * @return
	 */
	public default boolean verification(JSTableModel<?> model, Map<Integer, String> msgs) {
		int columnCount = model.getColumnCount();
		int rowCount = model.getRowCount();
		boolean result = true;
		for (int i = 0; i < rowCount; i++) {
			for (int j = 0; j < columnCount; j++) {
				if (!this.check(model, i, j)) {
					result = false;
					if (msgs != null) {
						msgs.put(i, this.getMsg(model, i, j));
					}
				}
			}
		}
		return result;
	}

}
